export const useFetchResponse = async (body: {
  url: string;
  methods: string;
  body: any;
  params: any;
}) => {
  // 封装fetch请求
  // 设置baseUrk
  const baseUrl = process.env.BASEURL || "http://localhost:3000";
  // 获取token的Cookles
  const Token = useCookie("token");
  // 判断Token
  const { url, methods, params } = body;
  const HeaderOption: { Authorization?: string } = {};
  if (Token) {
    HeaderOption.Authorization = "Bearer" + Token;
  }
  const response = await $fetch.raw(url, {
    method: methods,
    headers: HeaderOption,
    baseURL: baseUrl,
    params: params,
  });
  // 统一拦截
  if (response.status == 200) {
    return response._data;
  } else if (response.status == 401) {
    console.log("权限不足");
  }
};
